package com.lxit.dao;

import com.lxit.pojo.Chapter;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface ChapterMapper {
    @Delete({
        "delete from tb_chapter",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into tb_chapter (id, name, ",
        "count, course_id)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{count,jdbcType=INTEGER}, #{courseId,jdbcType=INTEGER})"
    })
    int insert(Chapter record);

    int insertSelective(Chapter record);

    @Select({
        "select",
        "id, name, count, course_id",
        "from tb_chapter",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Chapter selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Chapter record);

    @Update({
        "update tb_chapter",
        "set name = #{name,jdbcType=VARCHAR},",
          "count = #{count,jdbcType=INTEGER},",
          "course_id = #{courseId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Chapter record);
}